package com.mybpm.admin

import com.easecurity.core.basis.UserDo
import com.easecurity.core.basis.b.User
import com.mybpm.admin.utils.ServletUtils
import com.mybpm.core.utils.ServletUtils as BpmServletUtils
import com.mybpm.core.BpmUserService
import grails.gorm.services.Service

/**
 * 用户相关服务
 */
@Service
public class UserService implements BpmUserService {

    /**
     * 获取当前登录用户信息
     */
    @Override
    public UserDo getCurrentUserDo() {
        UserDo userDo = ServletUtils.currentUser
        if (!userDo) {
            userDo = getUserDo((String) BpmServletUtils.getRequestBodyData().userId)
        }
        return userDo
    }

    /**
     * 获取用户信息
     *
     * @param userId
     */
    @Override
    public UserDo getUserDo(String userId) {
        UserDo userDo = new UserDo()
        userDo.user = new User(id: userId)
        return userDo
    }
}